package sf.database.meta;

import sf.database.dialect.DBDialect;
import sf.database.util.SimpleSQLTemplate;

import java.util.List;

/**
 * 级联上下文
 */
public class CascadeContext {
    /**
     * sql
     */
    private String sql;

    private List<ColumnMapping> paras;

    /**
     * 返回类型,非list,可以为Map.class,java bean,或者基本类型.
     */
    private Class<?> resultBeanClass;

    private TableMapping tableMapping;

    public String getSql() {
        return sql;
    }

    public String getSqlByDialect(DBDialect dialect) {
        if (sql == null) {
            return null;
        }
        return SimpleSQLTemplate.unwrapper(dialect, sql);
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    public List<ColumnMapping> getParas() {
        return paras;
    }

    public void setParas(List<ColumnMapping> paras) {
        this.paras = paras;
    }

    public Class<?> getResultBeanClass() {
        return resultBeanClass;
    }

    public void setResultBeanClass(Class<?> resultBeanClass) {
        this.resultBeanClass = resultBeanClass;
    }

    public TableMapping getTableMapping() {
        return tableMapping;
    }

    public void setTableMapping(TableMapping tableMapping) {
        this.tableMapping = tableMapping;
    }
}
